//
//  ViewController.m
//  YSBookRead
//
//  Created by Kyson on 2018/11/6.
//  Copyright © 2018 YangShen. All rights reserved.
//

#import "ViewController.h"
#import "YSReadParser.h"
#import "YSReadController.h"
#import "YSHUDManager.h"
#import "YSNetworking.h"
#import "YSStorageManager.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Book Read";
    
}

- (IBAction)goReadButtonCick:(id)sender {
    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"求魔" ofType:@"txt"];    
    
    [YSHUDManager showHUDMessage:@"请稍后，正在解析"];
    [YSReadParser parserLocalBook:path complete:^(YSReadBookModel *readBook) {
        [YSHUDManager hide];

        YSReadController *readVC = [[YSReadController alloc] init];
        readVC.readBook = readBook;
        [self.navigationController pushViewController:readVC animated:YES];

    }];
}

- (IBAction)goWebReadButtonClick:(id)sender {

    NSString *bookID = @"55eef8b27445ad27755670b9";
    YSReadBookModel *readBook = [YSStorageManager getReadBook:bookID];
    if (!readBook) {
        readBook = [YSReadBookModel readBookWithBookID:bookID];
        readBook.isLocalBook = NO;
    }

    YSReadController *readVC = [[YSReadController alloc] init];
    readVC.readBook = readBook;
    [self.navigationController pushViewController:readVC animated:YES];
}


@end
